package org.example.core.exception;


import lombok.Getter;
import lombok.Setter;
import org.example.core.enums.BizErrorEnum;

/**
 * 自定义业务异常
 * @author Calvin
 */
@Setter
@Getter
public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private Integer code;

    public BusinessException() {
        this(BizErrorEnum.RESULT_ERROR.getDesc());
    }

    public BusinessException(String message) {
        this(BizErrorEnum.RESULT_ERROR.getCode(), message);
    }

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(Integer code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }

    public BusinessException(Integer code, String message, Throwable cause,
                             boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = code;
    }

}
